﻿
@{
    Layout = null;
}

<!DOCTYPE html>

<html lang="zh-cn">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Login</title>
    <link href="~/lib/layui/css/layui.css" rel="stylesheet" />
    <link href="~/css/login.css" rel="stylesheet" />
</head>
<body>
    <div class="shuhan-login">
        <div class="shuhan-login-bg"></div>
        <div class="shuhan-login-wapper">
            <h2 class="shuhan-login-slogan">@ViewBag.Name</h2>
            <div class="shuhan-login-form">
                <h4 class="shuhan-login-title">登录</h4>
                <form action="/Account/Login" class="layui-form">
                    <div class="shuhan-login-row">
                        <div class="shuhan-login-col">
                            <i class="layui-icon">&#xe612;</i>
                            <span class="shuhan-login-input">
                                <input type="text" name="loginName" lay-verify="required" placeholder="用户名" />
                            </span>
                        </div>
                        <div class="shuhan-login-col"></div>
                    </div>
                    <div class="shuhan-login-row">
                        <div class="shuhan-login-col">
                            <i class="layui-icon">&#xe64c;</i>
                            <span class="shuhan-login-input">
                                <input type="password" name="password" lay-verify="required" placeholder="密码" />
                            </span>
                        </div>
                        <div class="shuhan-login-col"></div>
                    </div>
                    <div class="shuhan-login-row">
                        <div class="shuhan-login-col">
                            <input type="checkbox" name="rememberMe" value="true" title="记住帐号" lay-skin="primary">
                        </div>
                    </div>
                    <div class="shuhan-login-row">
                        <button class="layui-btn shuhan-login-btn" lay-submit="submit" lay-filter="login">登录</button>
                    </div>
                    <div class="shuhan-login-row" style="margin-bottom:0;">
                        <a href="javascript:;" style="color: rgb(153, 153, 153); text-decoration: none; font-size: 13px;" id="forgot">忘记密码</a>
                    </div>
                </form>
            </div>
        </div>
    </div>
    <script src="~/lib/layui/layui.js"></script>
    <script src="~/lib/layui/Expand/LayuiExpand.js"></script>
    <script>
        layui.use(['layer', 'form', "md5"], function () {
            var form = layui.form,
                $ = layui.jquery,
                md5 = layui.md5;

            $('#forgot').on('click', function () {
                layer.msg('请联系管理员.');
            });

            //监听提交
            $(window).on('load', function () {
                form.on('submit(login)', function (data) {
                    var loadIndex = layer.load(2, {
                        shade: [0.3, '#333']
                    });
                    data.field.password = md5(data.field.password);
                    $.ajax({
                        url: data.form.action,
                        type: "post",
                        data: data.field,
                        success: function (res) {
                            if (!res.success) {
                                layer.msg(res.message, {
                                    icon: 2
                                });
                                loadIndex && layer.close(loadIndex);
                            } else {
                                setTimeout(function () {
                                    location.href = getQueryString("ReturnUrl");
                                }, 1500);
                            }
                        }
                    });
                    //$.post(data.form.action, JSON.stringify(data.field), function (res) {
                    //    if (res.state != 1) {
                    //        layer.msg(res.message, {
                    //            icon: 2
                    //        });
                    //        loadIndex && layer.close(loadIndex);
                    //    } else {
                    //        setTimeout(function () {
                    //            location.href = res.message;
                    //        }, 1500);
                    //    }
                    //}, 'application/json');
                    return false;
                });
            }());
            function getQueryString(name) {
                var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
                var r = window.location.search.substr(1).match(reg);
                if (r != null) return unescape(r[2]); return null;
            }
        });
    </script>
</body>
</html>
